/*
 * @(#)CityQueryParasBuilder.java
 * Copyright (c) 2011 TravelSky Technology Ltd. All Right Reserved. 
 */
package com.meetingshow.meeting.service.util;

import java.util.Map;

import org.apache.commons.lang.StringUtils;
import com.meetingshow.common.base.dao.model.QueryStruct;
import com.meetingshow.common.base.service.BaseQueryParasBuilder;
import com.meetingshow.meeting.service.model.CityQueryParas;

public class CityQueryParasBuilder extends BaseQueryParasBuilder {
    public static QueryStruct cityQueryBuilder(QueryStruct queryStruct, CityQueryParas cityQueryParas) throws Exception {
        builderInit(cityQueryParas, queryStruct);
        Map<String, Object> exactMap = queryStruct.getExactMap();
        Map<String, String> mistinessMap = queryStruct.getMistinessMap();
        
        if (StringUtils.isNotBlank(cityQueryParas.getCityId_e())) {
            exactMap.put(CityServiceParas.CITYPO_CITYID, Integer.valueOf(cityQueryParas.getCityId_e()));
        }
        if (StringUtils.isNotBlank(cityQueryParas.getAbbrev())) {
            mistinessMap.put("upper(" + CityServiceParas.CITYPO_ABBREV + ")", cityQueryParas.getAbbrev().toUpperCase());
        }
        if (StringUtils.isNotBlank(cityQueryParas.getName())) {
            mistinessMap.put("upper(" + CityServiceParas.CITYPO_NAME + ")", cityQueryParas.getName().toUpperCase());
        }
        if (StringUtils.isNotBlank(cityQueryParas.getNameEn())) {
            mistinessMap.put("upper(" + CityServiceParas.CITYPO_NAMEEN + ")", cityQueryParas.getNameEn().toUpperCase());
        }
        pageBuilder(queryStruct, cityQueryParas);
        
        return queryStruct;
    }
}
